package com.ctsi.security.service;

import com.ctsi.commons.event.BaseEvent;
import com.ctsi.commons.event.EventPublisherMan;
import com.ctsi.commons.util.UtilValidate;
import com.ctsi.commons.util.id.UUIDGenerator;
import com.ctsi.commons.util.response.Page;
import com.ctsi.framework.mybatis.support.MybatisGenericDao;
import com.ctsi.security.FetchObjIds;
import com.ctsi.security.ISecurity;
import com.ctsi.security.domain.DataObject;
import com.ctsi.security.domain.DataObjectType;
import com.ctsi.security.domain.RoleDataObject;
import com.ctsi.security.domain.RolePermission;
import com.ctsi.security.manager.impl.SecurityImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.util.Assert;

import java.util.*;


/**
 * 实现对功能权限和数据权限的CRUD
 *
 * @author zhangjw
 *
 */
@Repository
public class RoleSecurityService {
	private Logger log=LoggerFactory.getLogger(RoleSecurityService.class);
	@Autowired
	private MybatisGenericDao dao;
    @Autowired
	private ISecurity security;
    @Autowired
	private DataObjectTypeService dataObjectTypeService;

	/**
	 * 发布事件
	 */
	@Autowired
	private EventPublisherMan publisherMan;



	/**
	 * 保存角色功能权限
	 *
	 * @param rolePermission
	 */
	public void saveRolePermission(RolePermission rolePermission) {
		Assert.notNull(rolePermission);
		String rpId=rolePermission.getId();
		if(UtilValidate.isEmpty(rpId)) {
			rolePermission.setId(UUID.randomUUID().toString());
		}
				
//		dao.saveObject(rolePermission);
		dao.insert(rolePermission);
		SecurityImpl.clearPersonPermision(rolePermission.getRoleId());
		SecurityImpl.removeCacheRole(rolePermission.getRoleId());
		/**
		 * 发布事件
		 */
		//发布事件
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("type", "permissionId");
		List<String> list=new ArrayList<String>();
		list.add(rolePermission.getPermissionId());
		map.put("permissionId", list);
		map.put("rolePermissionId", rolePermission);
		map.put("action", "add");
		BaseEvent be=new BaseEvent(this,"securityPermissionDo",map);
		this.publishEvent(be, null);
	}




	/**
	 * 删除角色功能权限
	 *
	 * @param id
	 */
	public void removeRolePermission(String id,String permissionId) {
		/**
		 * 发布事件
		 */
//		RolePermission oldObject=dao.get(RolePermission.class, id);
		List<RolePermission> temp=findRolePermission(new String[] {"id"}, new Object[] {id});
		Assert.notEmpty(temp,"No match RolePermission for this id:"+id);
		RolePermission oldObject=temp.get(0);
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("type", "permissionId");
		List<String> list=new ArrayList<String>();
		list.add(permissionId);
		map.put("permissionId", list);
		map.put("rolePermissionId", oldObject);
		map.put("action", "remove");
		log.debug("publishEvent event securityPermissionDo");
		BaseEvent be=new BaseEvent(this,"securityPermissionDo",map);
		this.publishEvent(be, null);
//		dao.removeObject(com.gentlesoft.security.domain.RolePermission.class, id);
		dao.remove(oldObject);
		SecurityImpl.clearPersonPermision(oldObject.getRoleId());
		SecurityImpl.removeCacheRole(oldObject.getRoleId());
	}

	/**
	 * 查询全部角色功能权限
	 *
	 * @return
	 */
	public List<RolePermission> findAllRolePermission() {
		return dao.find(RolePermission.class,(Map<String,Object>)null);


	}
	public List<RolePermission> findRolePermision(String roleId){		
		return (List<RolePermission>)dao.queryForList(RolePermission.class.getName()+".findRolePermision", roleId);
	}
	
	public List<RolePermission>  findPersenPermision(String loginId){
		return (List<RolePermission>)dao.queryForList(RolePermission.class.getName()+".findPersenPermision", loginId);
	}
	/**
	 * 根据条件查询角色功能数据
	 *
	 * @param field
	 * @param args
	 * @return
	 */
	public List<RolePermission> findRolePermission(String[] field,
			Object[] args) {

		if(field==null || args==null) {
			return new ArrayList<RolePermission>(0);
		}
		Assert.isTrue(field.length==args.length,"arguments's length not equal");
		Map<String,Object> params=new HashMap<String, Object>(field.length);
		for(int i=0;i<field.length;i++) {
			params.put(field[i].toLowerCase(), args[i]);
		}
		return dao.find(RolePermission.class, params);
	}

	/**
	 * 查询角色下的功能数据和查询角色下可添加的功能数据
	 * @param pageSize
	 * @param startIndex
	 * @param roleId
	 * @param action
	 * @return
	 */
	public Page queryRolePermission(int pageSize,int startIndex,String roleId,String action,String permissionId,String permissionName){
		if("view".equals(action)) {
			return queryRolePerView(pageSize,startIndex,roleId,action,permissionId,permissionName,null);
		}else {
			return queryRolePerOther(pageSize,startIndex,roleId,action,permissionId,permissionName,null);
		}

	}

	private Page queryRolePerView(int pageSize, int startIndex, String roleId, String action, String permissionId, String permissionName, Map<String, Object> otherCond) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("roleId", roleId);
		if(UtilValidate.isNotEmpty(permissionId))
			params.put("permissionId", "%" + permissionId + "%");
		if(UtilValidate.isNotEmpty(permissionName))
			params.put("permissionName", "%" + permissionName + "%");
		if (UtilValidate.isNotEmpty(otherCond)) {
			params.putAll(otherCond);
		}
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append(RolePermission.class.getName());
		stringBuilder.append(".queryRolePerm");
		Page tempPage=dao.queryPage(stringBuilder.toString(), params, startIndex, pageSize);
		convert(tempPage.getResult());
		return tempPage;
	}
	private Page queryRolePerOther(int pageSize, int startIndex, String roleId, String action, String permissionId, String permissionName, Map<String, Object> otherCond) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("roleId", roleId);
		if(UtilValidate.isNotEmpty(permissionId))
			params.put("permissionId", "%" + permissionId + "%");
		if(UtilValidate.isNotEmpty(permissionName))
			params.put("permissionName", "%" + permissionName + "%");
		if (UtilValidate.isNotEmpty(otherCond)) {
			params.putAll(otherCond);
		}
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append(RolePermission.class.getName());
		stringBuilder.append(".queryNoRolePerm");
		return dao.queryPage(stringBuilder.toString(), params, startIndex, pageSize);
	}

	private void convert(List<Map<String,Object>> list) {
		if(UtilValidate.isEmpty(list)) {
			return;
		}
		String[] keys=new String[] {"id","permissionId","permissionName","permissionTypeId","permissionTypeName"};
		for(Map<String,Object> map : list) {
			for(String key : keys) {
				if(map.get(key.toUpperCase())!=null) {
					map.put(key, map.get(key.toUpperCase()));
					map.remove(key.toUpperCase());
				}
			}
		}
	}




	/**
	 * 带权限的返回角色下的功能数据和查询角色下可添加的功能数据（gyz added at 2008-3-28)
	 * @param userLogin
	 * @param dataObjectType
	 * @param pageSize
	 * @param startIndex
	 * @param roleId
	 * @param action
	 * @param permissionId
	 * @param permissionName
	 * @return
	 */
	public Page queryRolePermission(String userLogin,String dataObjectType,String action,int pageSize,int startIndex,String roleId,String action1,String permissionId,String permissionName){
		if(security.isControl(userLogin, dataObjectType, action)) {
			//control
			List<String>dataObjectIds=security.getDataObjectIds(userLogin, dataObjectType, action);
			if(UtilValidate.isEmpty(dataObjectIds)) {
				return new Page();
			}
			Map<String,Object> args=new HashMap<String, Object>(1);
			if(dataObjectIds.size()==1) {
				args.put("dataObjectsId",dataObjectIds.get(0));
			}else {
				args.put("dataObjectsIds", dataObjectIds);
			}
			if("view".equals(action1)) {
				return queryRolePerView(pageSize, startIndex, roleId, action1, permissionId, permissionName, args);
			}else {
				return queryRolePerOther(pageSize, startIndex, roleId, action1, permissionId, permissionName, args);
			}
		}else {
			return queryRolePermission(pageSize, startIndex, roleId, action1, permissionId, permissionName);
		}

	}


	/**
	 * 保存角色数据权限
	 *
	 * @param roleDataObject
	 */
	public void saveRoleDataObject(RoleDataObject roleDataObject) {
		Assert.notNull(roleDataObject);
		String id=roleDataObject.getId();
		if(UtilValidate.isEmpty(id)) {
			roleDataObject.setId(UUID.randomUUID().toString());
		}
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("type", "dataObjectTypeId");
		List<String> list=new ArrayList<String>();
		list.add(roleDataObject.getDataObjectTypeId());
		map.put("dataObjectTypeId", list);
		map.put("roleDataObjectId", roleDataObject);
		BaseEvent be=new BaseEvent(this,"dataObjectIntoSrole",map);
		this.publishEvent(be, null);
		
//		dao.saveObject(roleDataObject);
		dao.insert(roleDataObject);
		//发布事件

		BaseEvent beafter=new BaseEvent(this,"securityPermissionDo",map);
		this.publishEvent(beafter, null);

	}

	/**
	 * 修改角色数据权限
	 *
	 * @param roleDataObject
	 */
	public void updateRoleDataObject(RoleDataObject roleDataObject) {
//		dao.updateObject(roleDataObject);
		dao.update(roleDataObject);
	}


	/**
	 * 删除角色数据权限
	 * @param id
	 * @param doTypeId
	 */
	public void removeRoleDataObject(String id,String doTypeId) {
//		RoleDataObject oldObject=dao.get(RoleDataObject.class, id);
//		dao.removeObject(com.gentlesoft.security.domain.RoleDataObject.class,
//				id);
		List<RoleDataObject> temp=this.findRoleDataObject(new String[] {"ID"}, new Object[] {id});
		Assert.notEmpty(temp);
		RoleDataObject oldObject=temp.get(0);
		dao.remove(oldObject);
		/**
		 * 发布事件
		 */
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("type", "dataObjectTypeId");
		List<String> list=new ArrayList<String>();
		list.add(doTypeId);
		map.put("dataObjectTypeId", list);
		map.put("roleDataObjectId", oldObject);
		BaseEvent be=new BaseEvent(this,"securityPermissionDo",map);
		this.publishEvent(be, null);
	}

	/**
	 * 查询全部角色数据权限
	 *
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<RoleDataObject> findAllRoleDataObject() {
//		String hql = " from com.gentlesoft.security.domain.RoleDataObject";
//		return dao.findAll(hql);
		return (List<RoleDataObject>)dao.queryForList(RoleDataObject.class+".selectByMap");
	}
	/**
	 * @param dataobject
	 * @return
	 */
	public List<DataObjectType> findAllRoleDataObject(String dataobject) {
		Map<String,Object> params=new HashMap<String, Object>();
		params.put("dataobjecttypeid", dataobject);
		return (List<DataObjectType>)dao.queryForList(DataObjectType.class.getName()+".selectByMap",params);
	}
	/**
	 * 条件查询角色数据权限
	 *
	 * @param field
	 * @param args
	 * @return
	 */
	public List<RoleDataObject> findRoleDataObject(String[] field,
			Object[] args) {

		if(field==null || args==null) {
			return new ArrayList<RoleDataObject>(0);
		}
		Assert.isTrue(field.length==args.length,"arguments's length not equal");
		Map<String,Object> params=new HashMap<String, Object>(field.length);
		for(int i=0;i<field.length;i++) {
			params.put(field[i].toLowerCase(), args[i]);
		}
		return dao.find(RoleDataObject.class, params);
	}



	/**
	 * 查看角色下的数据对象
	 * @param pageSize
	 * @param startIndex
	 * @param roleDataObject0
	 * @return
	 */
	public Page<Map<String,Object>> queryRoleDataObject(int pageSize, int startIndex, RoleDataObject roleDataObject0){
		Map<String,Object> param = new HashMap<String,Object>();
		param.put("roleId",roleDataObject0.getRoleId());
		if(UtilValidate.isNotEmpty(roleDataObject0.getDataObjectId())){
			param.put("dataObjectId",roleDataObject0.getDataObjectId());
		}
		if(UtilValidate.isNotEmpty(roleDataObject0.getDataObjectName())){
			param.put("dataObjectName",roleDataObject0.getDataObjectName());
		}
		if(UtilValidate.isNotEmpty(roleDataObject0.getDataObjectTypeId())){
			param.put("dataObjectTypeId",roleDataObject0.getDataObjectTypeId());
		}
		if(UtilValidate.isNotEmpty(roleDataObject0.getDataObjectAction())){
			param.put("dataObjectAction",roleDataObject0.getDataObjectAction());
		}
		Page<RoleDataObject> listRoleDataObject=dao.queryPage(RoleDataObject.class.getName()+".select", param, startIndex, pageSize);
		List<Map<String,Object>> listMap=new ArrayList<Map<String,Object>>();
		List<RoleDataObject> list=listRoleDataObject.getResult();
		for(int i=0;i<list.size();i++){
			RoleDataObject roleDataObject=list.get(i);
			Map<String,Object> map=new HashMap<String,Object>();
					map.put("id", roleDataObject.getId());
					map.put("dataObjectId",roleDataObject.getDataObjectId());
					map.put("dataObjectName",roleDataObject.getDataObjectName());
					if(roleDataObject.getDataObjectId().indexOf("ALL")>0)
						map.put("dataObjectName",roleDataObject.getDataObjectTypeName()+"全部数据对象");
					map.put("dataObjectTypeId", roleDataObject.getDataObjectTypeId());
					map.put("dataObjectTypeName",roleDataObject.getDataObjectTypeName());
					map.put("dataObjectAction",roleDataObject.getDataObjectAction());
				listMap.add(map);
		}
		Page<Map<String,Object>> page=new Page<Map<String,Object>>(startIndex,listRoleDataObject.getTotalCount(),pageSize,listMap);
//		return listRoleDataObject;
		return page;
	}


	//特定角色下可添加的数据对象
	public Page<Map<String,Object>> queryDataObjectRole(int pageSize,int startIndex,String roleId){
		//取该角色下可添加的数据对象
//		String hsql="from com.gentlesoft.security.domain.DataObjectType";
		List<DataObjectType> listDoType=dao.find(DataObjectType.class, (Map<String,Object>)null);
		List<Map<String,Object>> listMap=new LinkedList<Map<String,Object>>();

		for(int i=0;i<listDoType.size();i++){
			DataObjectType dot=listDoType.get(i);
//			String localHsql="from com.gentlesoft.security.domain.DataObject as do where do.dataObjectTypeId=?";
//			List<DataObject> listDo=dao.findAll(localHsql, new Object[]{dot.getDataObjectTypeId()});
			Map<String,Object> args=new HashMap<String, Object>(1);
			args.put("dataobjecttypeid", dot.getDataObjectTypeId());
			List<DataObject> listDo=dao.find(DataObject.class,args);
			Map<String,Object> map=new HashMap<String,Object>();
				map.put("id", UUIDGenerator.getId());
				map.put("dataObjectId",dot.getDataObjectTypeId()+"ALL");
				map.put("dataObjectName", "<font color='red'>"+dot.getDataObjectTypeName()+"全部数据对象"+"</font>");
				map.put("dataObjectTypeId", dot.getDataObjectTypeId());
				map.put("dataObjectTypeName", dot.getDataObjectTypeName());
			    map.put("dataObjectTypeAction", "ADD");
			    map.put("dataCount", Integer.toString(listDo.size()));
       			listMap.add(map);
			for(int j=0;j<listDo.size();j++){
				DataObject dataObject=listDo.get(j);
				Map<String,Object> localMap=new HashMap<String,Object>();
				localMap.put("id", dataObject.getId());
				localMap.put("dataObjectId",dataObject.getDataObjectId());
				localMap.put("dataObjectName",dataObject.getDataObjectName());
				localMap.put("dataObjectTypeId", dot.getDataObjectTypeId());
				localMap.put("dataObjectTypeName", dot.getDataObjectTypeName());
				localMap.put("dataObjectTypeAction", "ADD");
				localMap.put("dataCount", Integer.toString(listDo.size()-j-1));
       			listMap.add(localMap);
			}
		}
		Page<Map<String,Object>> page=new Page<Map<String,Object>>(startIndex,listMap.size(),listMap.size(),listMap);
		return page;
	}

	/**
	 * 查询某一数据对象类型下的子数据对象类型,参数为NULL表示查询一级数据类型（目前只有一级）（gyz added at 2008-3-29）
	 * @param typeId 数据对象类型ID
	 * @return 数据对象类型列表
	 */
	public List<DataObjectType> queryDataObjectType(String typeId){
		List<DataObjectType> result=new LinkedList<DataObjectType>();
		//判断type是否为NULL，如为NULL，表示查询一级数据类型
		if(typeId==null){//查询一级数据类型
//		  String hsql="from com.gentlesoft.security.domain.DataObjectType";
//		  result=dao.findAll(hsql);
			result=dao.find(DataObjectType.class, (Map<String,Object>)null);
		}else{//查询数据类型type下的子类型
		  //TODO 目前只有一级数据对象类型		
		}
		return result;
	}
    /**
     * 查询某一数据对象类型下的子数据对象类型,参数为NULL表示查询一级数据类型（目前只有一级）
     * permisionIdList 为分级授权设置的功能id
     * @param typeId
     * @param permisionIdList
     * @return
     */
	public List<DataObjectType> queryDataObjectType(String typeId,List<String> permisionIdList){
		
		Map<String,Object> params=new HashMap<String, Object>();
		params.put("secretTypeIdnull", "true");
		List<DataObjectType> result=new LinkedList<DataObjectType>();
		//判断type是否为NULL，如为NULL，表示查询一级数据类型
				if(typeId==null){//查询一级数据类型
					
				if(UtilValidate.isNotEmpty(permisionIdList))
					params.put("secretTypeIds", permisionIdList);
					
					result=(List<DataObjectType>)dao.queryForList(DataObjectType.class.getName()+".selectByMap",params);
				}else{//查询数据类型type下的子类型
				  //TODO 目前只有一级数据对象类型		
				}
				return result;
	}
	
	
	/**
	 * 查询某一数据对象类型下的数据对象集合(gyz added at 2008-3-29)
	 * @param typeId 数据对象类型的ID
	 * @return 数据对象列表
	 */
	public List<DataObject> queryDataObject(String typeId){

		Map<String,Object> args=new HashMap<String, Object>(1);
		if(UtilValidate.isNotEmpty(typeId))
			args.put("dataobjecttypeid", typeId);
		return dao.find(DataObject.class,args);
	}
	
	public List<DataObject> queryInnerDataObject(String typeId,String parent){
		Map<String,Object> params=new HashMap<String, Object>();
		
		params.put("dataobjecttypeid", typeId);

		params.put("parent", parent);	
		
		
		List<DataObject> list = (List<DataObject>)dao.queryForList(DataObject.class.getName()+ ".selectByMap", params);
		return list;
	}
	
	public List<DataObject> queryDataObject(String typeId,String parent){	
		DataObjectType dataObjectType = dataObjectTypeService.findByTypeId(typeId);
		//如果内置
		if(dataObjectType.isInner()){
			Map<String,Object> params=new HashMap<String, Object>();
	
			params.put("dataobjecttypeid", typeId);
			
			if(UtilValidate.isEmpty(parent)||typeId.equals(parent)){
				params.put("root", typeId);
			}else{
				params.put("parent", parent);	
			}		
			
			List<DataObject> list = (List<DataObject>)dao.queryForList(DataObject.class.getName() + ".selectByMap", params);
			return list;
		}
		//如果扩展	
		FetchObjIds fetchObjIds = dataObjectType.getFetchObjIds();
		//如果使用角色
		if(fetchObjIds.isUserRole()){
			return fetchObjIds.queryDataObject(typeId, parent);
		}
		return new ArrayList<DataObject>();
	}
	/**
	 * 根据当前用户数据权限的数据权限id查询
	 * wnagbf  add on 2011-10-13
	 * @param userLoginId
	 * @param action
	 * @param typeId
	 * @param parent
	 * @return
	 */
	public List<DataObject> queryDataObject(String userLoginId,String dataObjectTyeStr,String action,String typeId,String parent){
		
		
		DataObjectType dataObjectType = dataObjectTypeService.findByTypeId(typeId);
		//如果内置
		if(dataObjectType.isInner()){
			Map<String,Object> params=new HashMap<String, Object>();
	
			if(!security.isControl(userLoginId, dataObjectTyeStr, action))
			{
				params.put("sysDataObjectids", null);
			}else{
				List<String> items = security.getDataObjectIds(userLoginId, dataObjectTyeStr, action);
				log.info("数据对象为{}", items);
				if(UtilValidate.isNotEmpty(items)){
					params.put("sysDataObjectids", items);	
				}
			}
			
			params.put("dataobjecttypeid", typeId);
			
			if(UtilValidate.isEmpty(parent)||typeId.equals(parent)){
				params.put("root", typeId);
			}else{
				params.put("parent", parent);	
			}		
			List<DataObject> list = (List<DataObject>)dao.queryForList(DataObject.class.getName()+ ".selectByMap", params);
			return list;
		}
		//如果扩展	
		FetchObjIds fetchObjIds = dataObjectType.getFetchObjIds();
		//如果使用角色
		if(fetchObjIds.isUserRole()){
			return fetchObjIds.queryDataObject(typeId, parent);
		}
		return new ArrayList<DataObject>();
	
		
	}
	public Page<DataObject> queryDataObject(String typeId,Map<String,Object> map,int start ,int pageSize){
		DataObjectType dataObjectType = dataObjectTypeService.findByTypeId(typeId);
		if(dataObjectType==null){
			log.info("数据对象为空");
			return new Page<DataObject>();
		}		
		if(dataObjectType.isInner()){
			map.put("dataobjecttypeid", typeId);
			return dataObjectTypeService.getDataObjectService().queryDataObject(pageSize, start, map);
		}else{			
			log.info("扩展的数据对象类行");
			FetchObjIds fetchObjIds = dataObjectType.getFetchObjIds();
			//如果使用角色
			if(fetchObjIds.isUserRole()){
				return fetchObjIds.queryDataObjectPage(typeId, map, start, pageSize);
			}
			
			return new Page<DataObject>();
		}
		
	}

	/**
	 * //是否存在该角色下，该数据对象，该操作的数据
	 * @param roleId
	 * @param dataObjectId
	 * @param dataObjectAction
	 * @return
	 */
	public boolean ValData(String roleId,String dataObjectId,String dataObjectAction ) {
		List<RoleDataObject> listRoleDataObject=this.findRoleDataObject(new String[]{"roleId","dataObjectId","dataObjectAction"}, new Object[]{roleId,dataObjectId,dataObjectAction});
		if(listRoleDataObject.size()>0){
			return true;
		}else{
			return false;
		}
	}
	
	/**
	 * //是否存在该角色下(根据数据权限类型)，该数据对象，该操作的数据
	 * @param roleId
	 * @param dataObjectId
	 * @param dataObjectAction
	 * @param dataObjectTypeId
	 * @return
	 */
	public boolean ValData(String roleId,String dataObjectId,String dataObjectAction,String dataObjectTypeId){
		List<RoleDataObject> listRoleDataObject=this.findRoleDataObject(new String[]{"roleId","dataObjectId","dataObjectAction","dataObjectTypeId"}, new Object[]{roleId,dataObjectId,dataObjectAction,dataObjectTypeId});
		if(listRoleDataObject.size()>0){
			return true;
		}else{
			return false;
		}
	}
	
	/**
	 * 发布事件
	 *
	 * @param baseEvent
	 * @param args
	 */
	private void publishEvent(BaseEvent baseEvent, Object args) {
		publisherMan.getEventPublisher().publishEvent(baseEvent, args);
	}

	public void setPublisherMan(EventPublisherMan publisherMan) {
		this.publisherMan = publisherMan;
	}

	public MybatisGenericDao getDao() {
		return dao;
	}


	public void setDao(MybatisGenericDao dao) {
		this.dao = dao;
	}

	public void setSecurity(ISecurity security) {
		this.security = security;
	}

	public DataObjectTypeService getDataObjectTypeService() {
		return dataObjectTypeService;
	}


	public void setDataObjectTypeService(DataObjectTypeService dataObjectTypeService) {
		this.dataObjectTypeService = dataObjectTypeService;
	}

}
